package com.housekeeper.common.exception;

import com.housekeeper.common.response.ResponseEnum;
import com.housekeeper.common.response.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice//进行异常拦截  @RestControllerAdvice = @ControllerAdvice + @ResponseBody
public class GlobalExceptionHandler {



    @ExceptionHandler(value = HKException.class)  // 捕获异常
    public Result handleLeadNewsException(HKException e){
        return Result.errorResult(e.getStatus(),e.getMessage());
    }
        
    
    /**
     * 捕获系统异常
     */
    @ExceptionHandler(value = Exception.class)  // 捕获异常
    public Result handleException(Exception e){
         return Result.errorResult(ResponseEnum.SERVER_ERROR.getCode(),e.getMessage());

    }


}
